CatchEvent OnLapperStart()
OnLapperStart_Register_ID();
EndCatchEvent
CatchEvent OnMSO( $userName, $text ) # Player event
$idxOfFirtsSpace = indexOf( $text, " ");
$userName = GetCurrentPlayerVar("UserName");
UserGroupFromFile( "admin", "./../AB-Configs/admin.txt" );
IF( $idxOfFirtsSpace == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirtsSpace );
$argv = trim( subStr( $text,$idxOfFirtsSpace ) );
ENDIF
SWITCH( $command )
CASE "!pay_divident":
CASE "!pd":
IF( UserInGroup( "admin", $userName ) == 1 )
THEN
Pay_divident( $KeyFlags );
ELSE
PrivMsg( "^1You are not allowed to do that");
ENDIF
BREAK;
ENDSWITCH
EndCatchEvent
CatchEvent OnConnect( $userName )
OnConnect_Register_ID();
EndCatchEvent
Sub OnLapperStart_Register_ID()
### Declare global variables ###
GlobalVar $register_counter;
### End ###
### Load stored values and give them a default setting if no stored value has been found ###
$register_counter = GetStoredValue( "REGISTER_COUNTER" );
IF ($register_counter == "")
THEN
$register_counter=0;
ELSE
$register_counter = ToNum( GetStoredValue( "REGISTER_COUNTER" ) );
ENDIF
### End ###
EndSub
Sub OnConnect_Register_ID()
### Retrieve the username ###
$userName = GetCurrentPlayerVar( "UserName");
### End ###
### Set $user_found to 'no' ###
$user_found = "no";
### End ###
### Check if $userName is NOT empty ###
IF ( $userName != "" )
THEN
### Loop through already registered user accounts, looking for the current username ###
FOR ( $i = 0; $i < $register_counter; $i = $i + 1 )
IF ( GetStoredValue( "UserName_Number_" . $i ) == $userName )
THEN
GlobalMsg( "User already registered on system" );
GlobalMsg( "^7User ID: ^6" . $i );
writeline( "User already registered on system" );
$user_found = "yes";
BREAK;
ENDIF
ENDFOR
### End ###
### If username hasn't been found in registered users, register this user, raise $register_counter by 1 and write new value for REGISTER_COUNTER to the database ###
IF ( $user_found == "no" )
THEN
SetStoredValue( "UserName_Number_" . ToString( $register_counter ) , $userName );
SetUserStoredValue( $userName , "Cash" , 0 );
$register_counter = $register_counter+1;
SetStoredValue( "REGISTER_COUNTER" , $register_counter );
GlobalMsg( "^7New User (^6" . $userName . "^7) has been registered." );
GlobalMsg( "^7New User ID: ^6" . ToNum( $register_counter ) );
writeline( "^7New User (^6" . $userName . "^7) has been registered." );
ENDIF
### End ###
ENDIF
### End ###
EndSub
Sub Pay_divident( $KeyFlags )
$Divident = 50;
### Loop through already registered user accounts, looking for the current username ###
FOR ( $i = 0; $i < $register_counter; $i = $i + 1 )
$IDUser = GetStoredValue( "UserName_Number_" . $i );
$cash = GetUserStoredValue( $IDUser, "Cash" );
$new_cash = ToNum ( Round( $cash + $Divident,2 ) );
writeline( "attempting to give user " . $IDUser . " cash from " . GetUserStoredValue( $IDUser, "Cash" ) );
SetUserStoredValue( $IDUser , "Cash", $new_cash );
writeline( "attempted to give user " . $IDUser . " cash to " . GetUserStoredValue( $IDUser, "Cash" ) );
ENDFOR
### End ###
EndSub
CatchEvent OnLapperStart()
OnLapperStart_Register_ID();
EndCatchEvent
CatchEvent OnConnect( $userName )
OnConnect_Register_ID();
EndCatchEvent
Sub OnLapperStart_Register_ID()
### Declare global variables ###
GlobalVar $register_counter;
### End ###
### Load stored values and give them a default setting if no stored value has been found ###
$register_counter = GetStoredValue( "REGISTER_COUNTER" );
IF ($register_counter == "")
THEN
$register_counter=0;
ELSE
$register_counter = ToNum( GetStoredValue( "REGISTER_COUNTER" ) );
ENDIF
### End ###
EndSub
Sub OnConnect_Register_ID()
### Retrieve the username ###
$userName = GetCurrentPlayerVar( "UserName");
### End ###
### Set $user_found to 'no' ###
$user_found = "no";
### End ###
### Check if $userName is NOT empty ###
IF ( $userName != "" )
THEN
### Loop through already registered user accounts, looking for the current username ###
FOR ( $i = 0; $i < $register_counter; $i = $i + 1 )
IF ( GetStoredValue( "UserName_Number_" . $i ) == $userName )
THEN
GlobalMsg( "User already registered on system" );
GlobalMsg( "^7User ID: ^6" . $i );
writeline( "User already registered on system" );
$user_found = "yes";
BREAK;
ENDIF
ENDFOR
### End ###
### If username hasn't been found in registered users, register this user, raise $register_counter by 1 and write new value for REGISTER_COUNTER to the database ###
IF ( $user_found == "no" )
THEN
SetStoredValue( "UserName_Number_" . ToString( $register_counter ) , $userName );
$register_counter = $register_counter+1;
SetStoredValue( "REGISTER_COUNTER" , $register_counter );
GlobalMsg( "^7New User (^6" . $userName . "^7) has been registered." );
GlobalMsg( "^7New User ID: ^6" . ToNum( $register_counter ) );
writeline( "^7New User (^6" . $userName . "^7) has been registered." );
ENDIF
### End ###
ENDIF
### End ###
EndSub
CatchEvent OnLapperStart()
OnLapperStart_PB();
EndCatchEvent
CatchEvent OnPB( $userName )
OnPB_announce();
EndCatchEvent
Sub OnLapperStart_PB()
### Declare global variable(s) ###
GlobalVar $AS3_E;
### End ###
### Give global variable(s) a value to start with ###
$AS3_E = MSHToNum("1.48.00");
### End ###
writeline ( "DEBUG1: " . $AS3_E );
EndSub
Sub OnPB_announce()
writeline ( "DEBUG2: " . GetCurrentPlayerVar( "LapTime" ) );
writeline ( "DEBUG3: " . NumToMSH( $AS3_E ) );
IF ( NumToMSH( GetCurrentPlayerVar( "LapTime" ) ) <= NumToMSH( $AS3_E ) )
THEN
cmdLFS("/msg ^7New PB by " . GetCurrentPlayerVar("NickName") . "^7 (" . GetCurrentPlayerVar("Car") . ") - " . NumToMSH(GetCurrentPlayerVar("LapTime")));
ENDIF
EndSub
CatchEvent OnLapperStart()
OnLapperStart_PB();
EndCatchEvent
CatchEvent OnPB( $userName )
OnPB_announce();
EndCatchEvent
Sub OnLapperStart_PB()
### Declare global variable(s) ###
GlobalVar $AS3_E;
### End ###
### Give global variable(s) a value to start with ###
$AS3_E = "1.48.00";
### End ###
writeline ( "DEBUG1: " . $AS3_E );
EndSub
Sub OnPB_announce()
writeline ( "DEBUG2: " . GetCurrentPlayerVar( "LapTime" ) );
writeline ( "DEBUG3: " . MSHToNum( $AS3_E ) );
IF ( GetCurrentPlayerVar( "LapTime" ) <= MSHToNum( $AS3_E ) )
THEN
cmdLFS( "/msg ^7New PB by " . GetCurrentPlayerVar("NickName") . "^7 (" . GetCurrentPlayerVar("Car") . ") - " . NumToMSH(GetCurrentPlayerVar("LapTime")));
ENDIF
EndSub